{extend name="public/base" /}
{block name="container"}
<div class="panel panel-default">
  <div class="panel-heading">
    <h4 class="panel-title">添加用户</h4>
  </div>
  <div class="panel-body panel-body-nopadding">

    <form class="form-horizontal form-bordered" id="submitForm" action="" method="post" >
      <div class="form-group">
        <label class="col-sm-3 control-label">卡号:</label>
        <div class="col-sm-6">
          <input type="text" class="form-control" name="card_num" placeholder="请输入卡号"  value="{$data.card_num ?? ''}"  required {if condition="$Request.action eq 'update'"} readonly{/if}>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-3 control-label">密码:</label>
        <div class="col-sm-6">
          <input type="password" class="form-control" name="password" placeholder="请输入密码" required value="{$data.password ?? ''}" {if condition="$Request.action eq 'update'"} readonly{/if}>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-3 control-label">确认密码:</label>
        <div class="col-sm-6">
          <input type="password" class="form-control" name="md5_pas" placeholder="请输入确认密码" required value="{$data.md5_pas ?? ''}" {if condition="$Request.action eq 'update'"} readonly{/if}>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-3 control-label"><span>*</span>真实姓名：</label>
        <div class="col-sm-6">
          <input type="text" class="form-control" placeholder="真实姓名" name="name" value="{$data.name ?? ''}"  required>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-3 control-label">性别：</label>
        <div class="col-sm-6 wh-inline">
          <div class="rdio rdio-primary">
            <input type="radio" name="sex" id="sex-1" value="1">男
            <input type="radio" name="sex" id="sex-2" value="2">女
          </div>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-3 control-label"><span>*</span>手机号：</label>
        <div class="col-sm-6">
          <input type="text" class="form-control" placeholder="手机号" name="phone" value="{$data['phone'] ?? ''}"  required>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-3 control-label"><span>*</span>身份证号码：</label>
        <div class="col-sm-6">
          <input type="text" class="form-control" placeholder="身份证号码" name="id_number" value="{$data['id_number'] ?? ''}" required>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-3 control-label"><span>*</span>金额：</label>
        <div class="col-sm-6">
          <input class="form-control" type="text" name="money" id="money" placeholder="请输入金额" datatype="*" value="{$data['money'] ?? ''}" required {if condition="$Request.action eq 'update'"} readonly{/if}>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-3 control-label"><span>*</span>赠送金额：</label>
        <div class="col-sm-6">
          <input class="form-control" type="text" name="song_money" id="song_money" placeholder="请输入金额" datatype="*" value="{$data['song_money'] ?? ''}" required {if condition="$Request.action eq 'update'"} readonly{/if}>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-3 control-label"><span>*</span>积分：</label>
        <div class="col-sm-6">
          <input class="form-control" type="text" name="jifen" id="jifen" placeholder="请输入金额" datatype="*" value="{$data['jifen'] ?? ''}" required {if condition="$Request.action eq 'update'"} readonly{/if}>
        </div>
      </div>
       
            <div class="form-group">
        <label class="col-sm-3 control-label">状态：</label>
        <div class="col-sm-6 wh-inline">
          <div class="rdio rdio-primary">
            <input type="radio" name="status" id="status-1" value="1">正常
            <input type="radio" name="status" id="status-2" value="0">冻结
          </div>
        </div>
      </div>
      <div class="panel-footer">
       <div class="row">
        <div class="col-sm-6 col-sm-offset-3">
          <input type="hidden" name="id" value="{$data.id ?? ''}">
          <button type="submit" class="btn btn-primary">提交</button>
          <button type="button" class="btn btn-default" onclick="javascript:history.back(-1);">返回</button>
        </div>
      </div>
    </div><!-- panel-footer -->

  </form>
</div>
{/block}
{block name="js"}
<script>
  $(function() {
    $("[name='status'][value='{$data.status ?? '0'}']").attr("checked", true);
    $("[name='sex'][value='{$data.sex ?? '1'}']").attr("checked", true);
    $('#money').change(function() {
      var num  = $('#money').val();
      document.getElementById('song_money').value = num;
      document.getElementById('jifen').value = num; 
    });
  });

  function getRegion(val,level)
    {
      var $city = $("#city");
      var $area = $("#area");
       if(level=='1'){
                    $city.html('<option value=""> --请选择市-- </option>');
                    $city.val('');
                }
                $area.html('<option value=""> --请选择区-- </option>');
                $area.val('');
      $.post('{:url('index/common/getRegion')}', { pcode: val,level:level}, function(data) {
               var dataObj=eval("("+data+")");//转换为json对象   
               if(dataObj['code']==1){
                if(level=='1'){
                    $.each(dataObj['list'], function(i, item) {
                      $city.append('<option value="'+item['code']+'">'+item['name']+'</option>');
                  });
                }else{
                    $.each(dataObj['list'], function(i, item) {
                      $area.append('<option value="'+item['code']+'">'+item['name']+'</option>');
                  });
                }
            }
        });
  }
</script>
{/block}